/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.azon.left.hand;

/**
 *
 * @author Mahdan Ahmad F A
 */
public class MatrixConverter {
    public int[][] blackAndWhiteConverter(int[][] matrix) {
        int[][] new_matrix = new int[matrix.length][matrix[0].length];
                
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                if (matrix[m][n] > 120) {
                    new_matrix[m][n] = 1;
                } else {
                    new_matrix[m][n] = 0;
                }
            }
        }
        
        return new_matrix;
    }
    
    public int[][] blackAndWhiteReverser(int[][] matrix) {
        int[][] new_matrix = new int[matrix.length][matrix[0].length];
                
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                if (matrix[m][n] == 1) {
                    new_matrix[m][n] = 0;
                } else {
                    new_matrix[m][n] = 1;
                }
            }
        }
        
        return new_matrix;        
    }
    
    public int[][] blackAndWhiteReverter(int[][] matrix) {
        int[][] new_matrix = new int[matrix.length][matrix[0].length];
                
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                if (matrix[m][n] > 0) {
                    new_matrix[m][n] = 255;
                    n++;
                } else {
                    new_matrix[m][n] = 0;
                }
            }
        }
        
        return new_matrix;
    }
    
    public int[][] detectConverter(int[][] matrix) {
        int[][] new_matrix = new int[matrix.length][matrix[0].length];
                
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                if (matrix[m][n] > 50) {
                    new_matrix[m][n] = 255;
                    n++;
                } else {
                    new_matrix[m][n] = 0;
                }
            }
        }
        
        return new_matrix;
    }
 
    public int[][] smootherConverter(int[][] matrix) {
        int[][] new_matrix = new int[matrix.length][matrix[0].length];
                
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                if (matrix[m][n] > 70) {
                    new_matrix[m][n] = 255;
                } else {
                    new_matrix[m][n] = 0;
                }
            }
        }
        
        return new_matrix;
    }
    
}
